/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.TaskManager;
/*    */ import com.newcrm.exception.DBException;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintWriter;
/*    */ import java.sql.SQLException;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import net.sf.json.JSONObject;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class DeleteTask extends AbstractAction
/*    */ {
/* 26 */   private static Logger logger = Logger.getLogger(DeleteTask.class.getName());
/*    */ 
/* 28 */   private int id = 0;
/*    */ 
/*    */   public DeleteTask(AbstractHttpServlet servlet) {
/* 31 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public DeleteTask(AbstractHttpServlet servlet, String id) {
/* 35 */     super(servlet);
/* 36 */     this.id = Util.str2Int(id);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 42 */     User loginUser = super.getLoginUser(request);
/* 43 */     String userId = loginUser.userId;
/* 44 */     TaskManager manager = new TaskManager();
/* 45 */     response.setContentType("text/html;charset=utf-8");
/* 46 */     PrintWriter out = response.getWriter();
/* 47 */     JSONObject jsonObject = new JSONObject();
/*    */ 
/* 49 */     if (this.id == 0) {
/* 50 */       this.id = Util.getURLIntParameter(request.getParameter("id"));
/*    */     }
/*    */     try
/*    */     {
/* 54 */       int result = manager.delete(this.id, userId);
/* 55 */       jsonObject.put("error", "0");
/* 56 */       jsonObject.put("result", Integer.valueOf(result));
/*    */     }
/*    */     catch (DBException e) {
/* 59 */       logger.warn("delete task failed", e);
/* 60 */       jsonObject.put("error", "1");
/* 61 */       jsonObject.put("msg", "删除任务的过程中发现错误，请稍后再试");
/*    */     } catch (SQLException e) {
/* 63 */       logger.warn("delete task failed", e);
/* 64 */       jsonObject.put("error", "1");
/* 65 */       jsonObject.put("msg", "删除任务的过程中发现错误，请稍后再试");
/*    */     }
/* 67 */     out.println(jsonObject);
/* 68 */     out.flush();
/* 69 */     out.close();
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.DeleteTask
 * JD-Core Version:    0.6.1
 */